﻿using System;
using Cocos2D;

namespace TestTiger.Screens
{
    public abstract class SceneBase : CCScene
    {
        public bool BackPressed;

        public SceneBase()
        {
            this.Init();
        }

        public override void Visit()
        {
            if (BackPressed)
            {
                BackPressed = false;
                bool quit = false;
                OnBackkeyPreesed(ref quit);
                if (quit)
                {
#if WP8
                    StatisticsHelper.EndAsync();
                    App.Current.Terminate();
#else
                    throw new Exception("Quit");
#endif
                }
            }
            base.Visit();
        }

        public virtual void OnBackkeyPreesed()
        {
        }
        public virtual void OnBackkeyPreesed(ref bool quitGame)
        {
            OnBackkeyPreesed();
        }
    }
}